/**
 * created by 小卷毛, 2019-09-23 023
 * Copyright (c) 2019, 416143467@qq.com All Rights Reserved.
 * #                   *********                            #
 * #                  ************                          #
 * #                  *************                         #
 * #                 **  ***********                        #
 * #                ***  ****** *****                       #
 * #                *** *******   ****                      #
 * #               ***  ********** ****                     #
 * #              ****  *********** ****                    #
 * #            *****   ***********  *****                  #
 * #           ******   *** ********   *****                #
 * #           *****   ***   ********   ******              #
 * #          ******   ***  ***********   ******            #
 * #         ******   **** **************  ******           #
 * #        *******  ********************* *******          #
 * #        *******  ******************************         #
 * #       *******  ****** ***************** *******        #
 * #       *******  ****** ****** *********   ******        #
 * #       *******    **  ******   ******     ******        #
 * #       *******        ******    *****     *****         #
 * #        ******        *****     *****     ****          #
 * #         *****        ****      *****     ***           #
 * #          *****       ***        ***      *             #
 * #            **       ****        ****                   #
 */
package com.aifeng.common_ui.helper

/**
 * 项目名称：Smart_Business
 * 创建人：小卷毛
 * 创建时间：2019-09-23 16:34
 */

fun String?.toFormatString(
    sFormat: String = "yyyy-MM-dd'T'HH:mm:ss",
    eFormat: String = "yyyy-MM-dd HH:mm:ss"
): String =
    when {
        this@toFormatString.isNullOrEmpty() -> ""
        else -> {
            val gValues = TimeHelper.getInstance().stringToLong(sFormat, this)
            TimeHelper.formatGMTUnixTime(gValues, eFormat)
        }
    }

fun String?.toFormat(
    sFormat: String = "yyyy-MM-dd HH:mm:ss",
    eFormat: String = "yyyy-MM-dd"
): String =
    when {
        this@toFormat.isNullOrEmpty() -> ""
        else -> TimeHelper.getInstance().stringToString(sFormat, eFormat, this)
    }

fun Long?.getTimeString(format: String = "yyyy-MM-dd HH:mm:ss"): String =
    when {
        this == null -> ""
        else -> TimeHelper.getInstance().getSecondFormatedDateTime(format, this)
    }

fun String?.getTimeString(format: String = "yyyy-MM-dd HH:mm:ss"): String =
    when {
        isNullOrEmpty() -> ""
        else -> TimeHelper.getInstance().getSecondFormatedDateTime(format, this.toNotLong())
    }

fun String?.isBefore(end: String, format: String = "yyyy-MM-dd") =
    when {
        this@isBefore.isNullOrEmpty() -> false
        end.isEmpty() -> false
        else -> TimeHelper.getInstance().isBefore(this, end, format)
    }






